package com.taobao.machinesystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taobao.machinesystem.entity.SysCompan;
import com.taobao.machinesystem.entity.vo.SysCompanQueryVo;
import com.taobao.machinesystem.mapper.SysCompanMapper;
import com.taobao.machinesystem.service.SysCompanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 公司表 服务实现类
 * </p>
 *
 * @author LiuJunCheng
 * @since 2022-04-22
 */
@Service
public class SysCompanServiceImpl extends ServiceImpl<SysCompanMapper, SysCompan> implements SysCompanService {

    @Override
    public Page<SysCompan> listSysCompan(Integer currentPage, Integer size, SysCompanQueryVo sysCompanQueryVo) {
        Page<SysCompan> sysCompanPage = new Page<>(currentPage,size);

        QueryWrapper<SysCompan> queryWrapper = new QueryWrapper<>();

        if (!StringUtils.isEmpty(sysCompanQueryVo.getCode())){
            queryWrapper.eq("CODE",sysCompanQueryVo.getCode());
        }
        if (!StringUtils.isEmpty(sysCompanQueryVo.getName())){
            queryWrapper.likeLeft("NAME",sysCompanQueryVo.getName());
        }
        if (!StringUtils.isEmpty(sysCompanQueryVo.getFDisable())){
            queryWrapper.eq("F_disable",sysCompanQueryVo.getFDisable());
        }

        return baseMapper.selectPage(sysCompanPage,queryWrapper);
    }
}
